<?php

namespace App\Http\Resources\Plane\PlaneOrder;

use App\Trip\Passengers\OrderSubPassenger;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use JsonSerializable;

class BeforeRefundPassengerResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param Request $request
     * @return array|Arrayable|JsonSerializable
     */
    public function toArray($request)
    {
        $passenger = parent::toArray($request);
        if (isset($passenger['sequence'])) {
            $passenger['passenger_id'] = OrderSubPassenger::buildSubPassengerId($passenger['passenger_id'], $passenger['sequence']);
        }
        return $passenger;
    }
}
